package _10_2;

import java.util.Locale;
import java.util.ResourceBundle;
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Locale[] supportedLocales = { Locale.UK, new Locale("bg", "BG") };
		Scanner scn = new Scanner(System.in);

		System.out.println("Choose your language:");
		for (int i = 0; i < supportedLocales.length; i++) {
			System.out.println("\t" + (i + 1) + ") "
					+ supportedLocales[i].getDisplayLanguage());
		}

		Locale currentLocale;
		try {
			currentLocale = supportedLocales[Integer.parseInt(scn.next()) - 1];
		} catch (ArrayIndexOutOfBoundsException e) {
			System.err.println("error: " + e.toString());
			e.printStackTrace();
			currentLocale = supportedLocales[0];
		} catch (NumberFormatException e) {
			System.err.println("error: " + e.toString());
			e.printStackTrace();
			currentLocale = supportedLocales[0];
		}

		ResourceBundle rb = ResourceBundle.getBundle("_10_2._10_2",
				currentLocale);
		System.out.println(rb.getString("YOUR_SELECTED_LANGUAGE_IS") + ".");
		
		Person person = new Person();
		System.out.print(rb.getString("ENTER_YOUR_FIRST_NAME") + ": ");
		person.firstName = scn.next();
		
		System.out.print(rb.getString("ENTER_YOUR_LAST_NAME") + ": ");
		person.lastName = scn.next();
		
		System.out.print(rb.getString("ENTER_YOUR_PHONE_NUMBER") + ": ");
		person.phoneNumber = scn.next();
		
		System.out.println();
		System.out.println(rb.getString("INPUTED_INFORMATION") + ":");
		person.print();
	}
}
